package com.jqr.activity.roomsqlitedemo.data;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.jqr.activity.roomsqlitedemo.model.User;

import kotlin.jvm.Volatile;

@Database(entities ={User.class},version = 1,exportSchema = false)
public abstract class JqrDatabase  extends RoomDatabase {
    public abstract UserDao userDao();

    private  JqrDatabase jqrDatabase;
    JqrDatabase getDatabase(Context context){
        synchronized (this){
            JqrDatabase instance=jqrDatabase;

            if(instance==null){
                instance= Room.databaseBuilder(
                        context.getApplicationContext(),
                        JqrDatabase.class,
                        "jqr"
                ).build();
                jqrDatabase=instance;
            }
        }
        return  jqrDatabase;

    }

}
